import Vue from 'vue'
import store from './store'
import App from './App'
import Net from "./request/index"
import API from './request/api.js'


// 引入全局TuniaoUI
import TuniaoUI from 'tuniao-ui'
Vue.use(TuniaoUI)
 
// 引入TuniaoUI提供的vuex简写方法
let vuexStore = require('@/store/$t.mixin.js')
Vue.mixin(vuexStore)

// // 分享
import share from '@/common/share.js'
Vue.prototype.$shareTitle = "拼鸭印刷"
Vue.prototype.$shareDesc = "拼鸭印刷，拼着印，更省钱"
Vue.prototype.$shareImg = null
Vue.prototype.$shareParam = null
Vue.mixin(share)


import Json from './Json' //测试用数据
const msg = (title, duration=1500, mask=false, icon='none')=>{
	//统一提示方便全局修改
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}
const json = type=>{
	//模拟异步请求数据
	return new Promise(resolve=>{
		setTimeout(()=>{
			resolve(Json[type]);
		}, 500)
	})
}

const prePage = ()=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}


Vue.config.productionTip = false
Vue.prototype.$fire = new Vue();
Vue.prototype.$store = store;
Vue.prototype.$api = {msg, json, prePage};


// 网络请求 与 本地缓存
Vue.prototype.$Net = Net
Vue.prototype.$API = API

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()